/**
 * 扩展Ext控件,继承于TextField,用于实现去掉输入值空格的功能,解决了输入空格,不能为空校验仍然通过的bug
 * Copyright(c) 2010
 * @author xietao
 * @version 1.0
 * Create Date: 2010/09/15
 */
Ext.form.ExtendTextField = Ext.extend(Ext.form.TextField,  
{
    getErrors: function(value)   //仅修改此方法,其它不变
    {
        var errors = Ext.form.TextField.superclass.getErrors.apply(this, arguments);
        
        value = value || this.processValue(this.getRawValue());        
        value = value.trim();  //the add code;modi by xietao 2010-09-15
        
        if (Ext.isFunction(this.validator))
        {
            var msg = this.validator(value);
            if (msg !== true) 
            {
                errors.push(msg);
            }
        }
        
        if (value.length < 1 || value === this.emptyText) 
        {
            if (this.allowBlank) 
            {
                //if value is blank and allowBlank is true, there cannot be any additional errors
                return errors;
            }
            else 
            {
                errors.push(this.blankText);
            }
        }
        
        if (!this.allowBlank && (value.length < 1 || value === this.emptyText)) //if it's blank
        {
            errors.push(this.blankText);
        }
        
        if (value.length < this.minLength) 
        {
            errors.push(String.format(this.minLengthText, this.minLength));
        }
        
        if (value.length > this.maxLength) 
        {
            errors.push(String.format(this.maxLengthText, this.maxLength));
        }
        
        if (this.vtype) 
        {
            var vt = Ext.form.VTypes;
            if(!vt[this.vtype](value, this))
            {
                errors.push(this.vtypeText || vt[this.vtype +'Text']);
            }
        }
        
        if (this.regex && !this.regex.test(value)) 
        {
            errors.push(this.regexText);
        }
        
        return errors;
    }
});
Ext.reg('extendtextfield', Ext.form.ExtendTextField);